contentformats: Change the format of gdk_content_formats_to_string()
authorBenjamin Otte <otte@redhat.com>
Mon, 26 Jul 2021 00:28:49 +0000 (02:28 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 26 Jul 2021 00:28:49 +0000 (02:28 +0200)
Now, we just print a whitespace-separated list of GTypes and mime types.

This makes this neat for 2 things:

1. Parsing it (see next commit)
2. Using it in GtkBuilder (see commits after that)

In particular, the common case of supporting a single GType (or mime
type) looks like just printing the GType (or mime type), which in
GtkBuilder looks like
<property name="formats">GdkTexture</property>

gdk/gdkcontentformats.c

index aa0541bd44b0ed7e5b267bac6d915e5641e4e758..24ac00ad149f4a1d2ca756e96e5687da9b406b24 100644 (file)
@@ -241,20 +241,18 @@ gdk_content_formats_print (GdkContentFormats *formats,
   g_return_if_fail (formats != NULL);
   g_return_if_fail (string != NULL);
 
-  g_string_append (string, "{ ");
   for (i = 0; i < formats->n_gtypes; i++)
     {
       if (i > 0)
-        g_string_append (string, ", ");
+        g_string_append (string, " ");
       g_string_append (string, g_type_name (formats->gtypes[i]));
     }
   for (i = 0; i < formats->n_mime_types; i++)
     {
       if (i > 0 || formats->n_gtypes > 0)
-        g_string_append (string, ", ");
+        g_string_append (string, " ");
       g_string_append (string, formats->mime_types[i]);
     }
-  g_string_append (string, " }");
 }
 
 /**